<?php

	/*	
		START---------------------------------------------------------------------------------
	
		Name	: clsHotspot.php
		Version	: 1.0
		Author	: Henrik Andersen
		Company : Linnaeus University, Media Technology
		Mail	: Henrik.Andersen@lnu.se
		Date	: 2010-11-22 10:50 CET
		
		DESCRIPTION----------------------------------------------------------------------------
		
		This is a hotspot objects and is used to "bind" content and events to a specific 
		geographic location.
	
		SYNTAX---------------------------------------------------------------------------------
		
		The following list contains the public functions that can be used externally.
		
		Method Name:						Short Description:
		
		* setMeta("ID_1234", "My Spot")		Set Layar Name.
		* getMeta()							Get the hotspot meta data.
		* setLocation()						Set the hotspot location.
		* getLocation()						get the hotspot location.
		* setImage()						set hotspot HUD image.
		* getImage()						get hotspot HUD image.
		* setLines()						set extra HUD information lines.
		* getLines()						get extra HUD information lines.
		* addAction()						add hotspot action event (clsAction.php).
		
		TO DO'S--------------------------------------------------------------------------------
		
		END------------------------------------------------------------------------------------
	*/
	
	// IMPORT
	
	require_once 'src/php/lib/QuickieLayar/Hotspot/clsTransform.php';
	require_once 'src/php/lib/QuickieLayar/Hotspot/clsObject.php';
	
	// PUBLIC CLASS
	
	class clsHotspot
	{				
		// PUBLIC CONSTANTS
		
		const POINT					= 1;
		const SPRITE				= 2;
		const OBJECT				= 3;
		
		// PUBLIC VARIABELS
		
		/*	
			All the variables are mandatory and must obtain a 
			value for the system to function properly.
		*/		
		
		public $id					= null;
		public $title 				= null;
		public $distance			= 250;
		public $type				= 0;
		public $lat					= 0;
		public $lon					= 0;
		public $actions				= array();
		
		/* 
			following variables are optional and do not need 
			a value in order to make the system work properly.
		*/
		
		public $line2				= null;
		public $line3				= null;
		public $line4				= null;
		public $attribution			= null;
		public $imageURL			= null;
		public $dimension			= self::POINT;
		public $object				= null;
		public $transform			= null;
		public $alt					= 0;
		public $relativeAlt			= 0;
		public $doNotIndex			= false;
		public $inFocus				= false;
		public $showSmallBiw		= true;
		public $showBiwOnClick		= true;
		
		// PRIVATE VARIABELS
		
		private $objUtilities		= null;
				
		// CONSTRUCTOR FUNCTION
		
		/*------------------------------------------------------------------------------------
		__construct:									
		This is the constructor function and it creates instances of the necessary 
		external classes.
		------------------------------------------------------------------------------------*/
		public function __construct()
		{
			$this->transform 	= new clsTransform();
			$this->object 	 	= new clsObject();
			$this->objUtilities	= new clsUtilities();
		}
		
		// PUBLIC FUNCTIONS
		
		/*------------------------------------------------------------------------------------
		setMeta:									
		Public Function to set the meta data for the hotspot.
		
		!strId		String		An ID-string for this hotspot.
		!strTitle	String		A name for this hotspot.
		------------------------------------------------------------------------------------*/
		public function setMeta($strId, $strTitle)
		{
			$this->id	 = $strId;
			$this->title = $strTitle;
		}
		
		/*------------------------------------------------------------------------------------
		getMeta:									
		Public function to get meta data from the hotspot.
		
		@return		Object		An object containing the hotspot id and title. 
		------------------------------------------------------------------------------------*/
		public function getMeta()
		{
			$objMeta		= new stdClass();
			$objMeta->id	= $this->id;
			$objMeta->title	= $this->title;
			
			return $objMeta;
		}
		
		/*------------------------------------------------------------------------------------
		setLocation:									
		Public funtion to set the location of the hotspot.
		
		!decLat		Decimal		The latitude of the hotspot. 
		!decLon		Decimal		The longitude of the hotspot.
		------------------------------------------------------------------------------------*/
		public function setLocation($decLat, $decLon)
		{
			$this->lat = $this->objUtilities->toIntLoc($decLat);
			$this->lon = $this->objUtilities->toIntLoc($decLon);
		}
		
		/*------------------------------------------------------------------------------------
		getLocation:									
		Public function to get the current location of the hotspot.
		
		@return		Object		An object containing the hotspot latitude and longitude.
		------------------------------------------------------------------------------------*/
		public function getLocation()
		{
			$objLocation		= new stdClass();
			$objLocation->lat	= $this->lat;
			$objLocation->lon	= $this->lon;
			
			return $objLocation;
		}
		
		/*------------------------------------------------------------------------------------
		setImage:									
		Public function to set an HUD image for the hotspot.
		
		!strImageURL		String		A valid image URL.
		------------------------------------------------------------------------------------*/
		public function setImage($strImageURL)
		{
			$this->imageURL = $strImageURL;
		}
		
		/*------------------------------------------------------------------------------------
		getImage:									
		Public function to get the current HUD image at the hotspot.
		
		@return		String		A valid image URL.
		------------------------------------------------------------------------------------*/
		public function getImage()
		{
			return $this->imageURL;
		}
		
		/*------------------------------------------------------------------------------------
		setLines:									
		Public function to set extra hotspot information.
		
		?strLine2		String		Text for the second HUD line.
		?strLine3		String		Text for the third HUD line.
		?strLine4		String		Text for the fourth HUD line.
		------------------------------------------------------------------------------------*/
		public function setLines($strLine2 = null, $strLine3 = null, $strLine4 = null)
		{
			$this->line2 = $strLine2;
			$this->line3 = $strLine3;
			$this->line4 = $strLine4;
		}
		
		/*------------------------------------------------------------------------------------
		getLines:									
		Public function to get extra hotspot information.
		
		@return		Object		An object containing the 2,3 and 4:e HUD line. 
		------------------------------------------------------------------------------------*/
		public function getLines()
		{
			$objLines			= new stdClass();
			$objLines->line2	= $this->line2;
			$objLines->line3	= $this->line3;
			$objLines->line4	= $this->line4;
			
			return $objLines;
		}
		
		/*------------------------------------------------------------------------------------
		addAction:									
		Use this public function to add a new action event to this Layar.
		
		!objAction		Object		A new action object (clsAction.php).
		------------------------------------------------------------------------------------*/
		public function addAction($objAction)
		{
			array_push($this->actions, $objAction);
		}
	}

?>